<template>
	<view class="status-wrap">
		<uni-tag
			class="status-label"
			:text="transText"
			:custom-style="transStyle"
		>
		</uni-tag>
	</view>
</template>

<script>
export default {
	name: 'BusLabel',
	dicts: [
		'order_status',
		'em_device_carry',
		'em_device_state',
		'device_run_state',
	],
	props: {
		type: {
			type: String,
			default: '',
		},
		value: {
			type: String | Number,
			default: '',
		},
	},
	computed: {
		// 标签状态，业务字段传 type 判断
		transText() {
			switch (this.type) {
				// 审批状态
				case 'approval':
					return this.dict.type.order_status.find(
						(i) => i.value == this.value,
					)?.label;
				// 工单执行状态
				case 'execute':
					return this.dict.type.em_device_carry.find(
						(i) => i.value == this.value,
					)?.label;
				// 设备运行状态
				case 'deviceRunning':
					return this.dict.type.device_run_state.find(
						(i) => i.value == this.value,
					)?.label;
				// 设备状态
				case 'device':
					return this.dict.type.em_device_state.find(
						(i) => i.value == this.value,
					)?.label;
				default:
					break;
			}
		},
		transStyle() {
			const styleMap = {
				1: {
					backgroundColor: '#ebf4f1',
					borderColor: '#cde1d0',
					color: '#2eab1f',
				},
				2: {
					backgroundColor: '#fefbf7',
					borderColor: '#fdf3e8',
					color: '#f28306',
				},
				3: {
					backgroundColor: '#e6e6fa',
					borderColor: '#800080',
					color: '#800080',
				},
			};
			return styleMap[this.value];
		},
	},
};
</script>

<style scoped lang="scss">
.status-wrap {
	position: absolute;
	right: 0;
	top: 80px;
	.status-label {
		font-weight: 700;
		border-radius: 30px 2px 2px 30px; /* Rounded corners, adjust values as needed */
		text-decoration: none; /* Remove underline from the text if it's a link */
	}
}
</style>
